package com.daidai.dao;

import com.daidai.domain.Book;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BookDao {

    @Select("select * from ssm_db.tbl_book")
    List<Book> getAllBooks();

    @Select("select * from ssm_db.tbl_book where id = #{id}")
    Book getBookById(int bookId);

    @Insert("insert into ssm_db.tbl_book(type, name, description) VALUES(#{type}, #{name}, #{description})")
    int insertBook(Book book);

    @Delete("delete from ssm_db.tbl_book where id = #{id}")
    int deleteBook(Integer id);

    @Update("update ssm_db.tbl_book set name = #{name}, type = #{type}, description = #{description} where id = #{id}")
    int updateBook(Book book);

}
